﻿using MySql.Data.MySqlClient;
using System.Collections.Generic;

namespace per.esmool.utils.DB.MySQL {

    public class MySQLDbManager : IDbManager<MySqlConnection> {

        private readonly string connectionString;

        readonly List<MySqlConnection> connections = [];

        public MySQLDbManager(string connectionString) {
            this.connectionString = connectionString;
        }

        public MySqlConnection Connection {
            get {
                var connection = new MySqlConnection(this.connectionString);
                connection.Open();
                return connection;
            }
        }

        public void Dispose() {
            foreach (var connection in this.connections) {
                connection.Clone();
                connection.Dispose();
            }
        }
    }

}
